package com.wlyuan.open.scanner.utils.enums.quotation;

import com.wlyuan.open.scanner.utils.DateUtils;
import com.wlyuan.open.scanner.utils.NumberUtils;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Optional;

/**
 * @author lijing
 * @description
 */
public class TemplateMapping {

    public BigDecimal changeNull(BigDecimal value) {
        return NumberUtils.changeNull(value);
    }

    public LocalDateTime defaultToNull(LocalDateTime localDateTime) {
        return DateUtils.dateTimeDefaultToNull(localDateTime);
    }

    public TemplateModeEnum createTemplateTypeValue(Integer value) {
        return TemplateModeEnum.fromValue(value);
    }

    public Integer getTemplateFromTypeValue(TemplateFromTypeEnum value) {
        return Optional.ofNullable(value).map(TemplateFromTypeEnum::getNewValue).orElse(null);
    }

    public TemplateStatusEnum createTemplateStatusValue(Integer value) {
        return TemplateStatusEnum.fromValue(value);
    }

    public Integer getTemplateStatusValue(TemplateStatusEnum value) {
        return Optional.ofNullable(value).map(TemplateStatusEnum::getNewValue).orElse(null);
    }

    public Integer getTemplateTypeValue(TemplateModeEnum value) {
        return Optional.ofNullable(value).map(TemplateModeEnum::getNewValue).orElse(null);
    }
}
